<?php

declare(strict_types=1);

namespace App\Game\Model;

use App\Fastapp\Model\Account;
use Hyperf\Database\Model\Relations\HasOne;
use Mine\MineModel;

/**
 * @property int $id 主键
 * @property int $user_id 用户id
 * @property int $game_id 游戏id
 * @property string $game_name 游戏名称
 * @property string $bet_id 主注单id
 * @property string $transaction_id 交易id
 * @property string $platform 平台
 * @property string $amount 下注额
 * @property string $payout 派彩额
 * @property string $result_amount 结果
 * @property int $rtp rtp
 * @property string $symbol symbol
 * @property int $result 1bet2win3lose
 * @property int $status 处理0否1是2杀单
 * @property string $pump 抽水
 * @property \Carbon\Carbon $created_at
 * @property \Carbon\Carbon $updated_at
 * @property-read null|Game $game
 * @property-read null|Account $account
 */
class GameBet extends MineModel
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'game_bet';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'user_id', 'game_id', 'game_name', 'bet_id', 'transaction_id', 'platform', 'amount', 'payout', 'result_amount', 'rtp', 'symbol', 'result', 'status', 'pump', 'created_at', 'updated_at'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'user_id' => 'integer', 'game_id' => 'integer', 'amount' => 'decimal:2', 'payout' => 'decimal:2', 'result_amount' => 'decimal:2', 'rtp' => 'integer', 'result' => 'integer', 'status' => 'integer', 'pump' => 'decimal:2', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    public function game(): HasOne
    {
        return $this->hasOne(Game::class, 'id', 'game_id');
    }

    public function account(): HasOne
    {
        return $this->hasOne(Account::class, 'gene_id', 'user_id');
    }
}
